using System;
using Castle.Core.Logging;

namespace DreamDriven.ObjectModel
{
    /// <summary>
    /// A manager for business logic operations.
    /// </summary>
    public abstract class BaseBusinessLogicManager : IBusinessLogicManager
    {
        /// <summary>
        /// Gets the domain model.
        /// </summary>
        protected IDomainModel DomainModel { get; private set; }

        public ILogger Logger { get; set; }

        /// <summary>
        /// Creates a new instance of AbstractBusinessLogicManager.
        /// </summary>
        /// <param name="domainModel">The domain model.</param>
        protected BaseBusinessLogicManager(IDomainModel domainModel)
        {
            if (domainModel == null)
            {
                throw new ArgumentNullException("domainModel", "Domain model cannot be null.");
            }
            DomainModel = domainModel;
        }

        protected T GetComponent<T>()
        {
            return ServiceLocator.Instance.GetComponent<T>();
        }

        protected T GetService<T>()
            where T: IDomainService
        {
            return ServiceLocator.Instance.GetService<T>();
        }
    }
}